﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    var appendixsetting = {
        check: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true
            }
        }
    };
    $(function() {
        intity_wfmrgtree();

    })

    function intity_wfmrgtree() {
        var wf_id = $("#wfmrg #wf_id").val();
        $.ajax({
            type: "POST",
            url: "/WorkFlow/DoGetUserTreeByWfId",
            data: { "wf_id": wf_id },
            success: function(userNodes) {
                setting.callback.onCheck = onUsertreeCheck_wfmrg;
                $.fn.zTree.init($("#treeDemo_wfrg"), setting, eval(userNodes));
            }
        });
    }

    function onUsertreeCheck_wfmrg(event, treeId, treeNode) {
        //alert(treeNode.id + ", " + treeNode.name + "," + treeNode.checked);
        var treeObj = $.fn.zTree.getZTreeObj("treeDemo_wfrg");
        var nodes = treeObj.getCheckedNodes(true);
        var temp_name = "";
        var temp_id = "";
        for (i = 0; i < nodes.length; i++) {
            //alert(nodes[i].level);
            if (nodes[i].tag == "用户") {//保证是第3层，即员工姓名这一层，非部门层
                temp_id = temp_id + nodes[i].id + ",";
                temp_name = temp_name + nodes[i].name + ",";
            }
        }
        $("#scter_ids").attr("value", temp_id);
        $("#scter_names").attr("value", temp_name);
    };

    function submit_wfmrg() {
        var scter_ids = $("#scter_ids").val();
        var wf_id = $("#wf_id").val();
        var wf_dxbz = $("#wf_dxbz").val();
        alert(scter_ids);
        $.ajax({
            url: "/WorkFlow/DoSaveWfFqqx",
            type: "POST",
            data: { "wf_id": wf_id, "scter_ids": scter_ids, "wf_dxbz": wf_dxbz },
            success: function(restag) {
                if (restag.res) {
                    alert("保存成功！");
                    $.fn.deltab('2-1-1');
                }
                else
                    alert(restag.msg);
            }
        });
    }
</script>

<div id="wfmrg">
    <div>
        <input class="btn_style" type="button" value="确定" onclick="submit_wfmrg()" />
    </div>
    <div style="margin-top: 20px;">
        <p>
            流程名称:<%=ViewData["wf_name"] %><%=Html.Hidden("wf_id",ViewData["wf_id"])%><%=Html.Hidden("scter_ids", ViewData["wf_fqrids"])%><%=Html.Hidden("treeNode", ViewData["treeNode"])%></p>
        <p>
            权限:</p>
        <p>
            短信提醒:
            <%=Html.DropDownList("wf_dxbz", ViewData["list_wfdxbz"] as List<SelectListItem>)%></p>
        <div id="div_tree" class="zTreeDemoBackground left" style="float: left; height: 240px;">
            <ul id="treeDemo_wfrg" class="ztree" style="height: 230px; width: 260px; float: left;">
            </ul>
        </div>
    </div>
</div>
